package ru.urfc.portal.ui.client.renderers;

import ru.urfc.portal.ui.client.descriptor.GridField;
import ru.urfc.portal.ui.client.widgets.MegaGrid;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.form.Field;

public class ExtFieldRenderer extends BaseRenderer {

	protected Field extField;
	
	public ExtFieldRenderer(GridField gridField, Field<?> extField) {
		super(gridField);
		this.extField = extField;
	}

	@Override
	protected void init(MegaGrid grid) {
	}

	@Override
	public Object renderCell(ModelData modelData) {
		return null;
	}

	public boolean validate() {
		return extField.validate();
	}

	@SuppressWarnings("unchecked")
	@Override
	public void renderElements(ModelData modelData) {
		extField.setValue(field.getValue(modelData));
	}
	
	@Override
	public void updateModel(ModelData modelData) {
		field.setValue(modelData, extField.getValue());
	}

}
